import matplotlib.pyplot as plt
import numpy as np

# 生成多组数据
data1 = np.random.normal(0, 1, 100)
data2 = np.random.normal(2, 1.5, 100)
data3 = np.random.normal(-1, 0.5, 100)

data = [data1, data2, data3]
labels = ['组1', '组2', '组3']

plt.figure(figsize=(8, 6))
plt.boxplot(data, labels=labels, patch_artist=True)
plt.title('多组数据箱线图比较')
plt.ylabel('数值')
plt.grid(True, alpha=0.3)
plt.show()